<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./function.js"></script>
</head>

<body>
    <input type="button" value="计算" onclick="sum1()">

<!-- 
    半径为：
    <input type="text" id="r" placeholder="r>0"><br>
    <input type="button" value="计算" onclick="getArea()"><br>
    圆的面积为：
    <input type="text" id="res2"> -->


    <!-- <input type="text" id="n" placeholder="0<n<=1000">
    <input type="button" value="计算" onclick="sum()">
    <input type="text" id="count"> -->
</body>
<script>

    // function sum() {
    //     let n = document.getElementById("n").value;
    //     let count;//计数器从零开始计数
    //     if (0 < n && n <= 1000 && !isNaN(n)) {
    //         count = 0;
    //         for (let i = 0; i <= n; i++) {
    //             count = count + i;
    //         }
    //         // return count;
    //         document.getElementById("count").value = count;
    //         return;
    //     } else {
    //         count = "请输入正确的数字"
    //         document.getElementById("count").value = count;
    //         return;
    //     }
    // }
    // let i = 1;
    // while (i <= n) {
    //     count += i;
    //     i++;
    // }
    // return count;
    // console.log(sum(100));


    // console.log(Math.PI.toFixed(2));
    //toFixed(X) 取到小数后面的X位

</script>

</html>